package org.andcool.animation.ease;

/**
 * @author Joosun
 * @since 2011-5-8
 */
public class EaseBounce extends BaseEase
{
	public EaseBounce(final EasingMode pEasingMode)
	{
		super(pEasingMode);
	}

	@Override
	protected float getEaseInInterpolation(final float pPercentage)
	{
		return 1 - this.getEaseOutInterpolation(1 - pPercentage);
	}

	@Override
	protected float getEaseOutInterpolation(float pPercentage)
	{
		if (pPercentage < (1 / 2.75))
		{
			return 7.5625f * pPercentage * pPercentage;
		}
		else if (pPercentage < (2 / 2.75))
		{
			return 7.5625f * (pPercentage -= (1.5f / 2.75f)) * pPercentage + 0.75f;
		}
		else if (pPercentage < (2.5 / 2.75))
		{
			return 7.5625f * (pPercentage -= (2.25f / 2.75f)) * pPercentage + 0.9375f;
		}
		else
		{
			return 7.5625f * (pPercentage -= (2.625f / 2.75f)) * pPercentage + 0.984375f;
		}
	}

	@Override
	protected float getEaseInOutInterpolation(final float pPercentage)
	{
		if (pPercentage < 0.5f)
		{
			return this.getEaseInInterpolation(pPercentage * 2) * 0.5f;
		} else
		{
			return this.getEaseOutInterpolation(pPercentage * 2 - 1) * 0.5f + 0.5f;
		}
	}
}